#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{

    //[]
    // QPushButton* btn1 = new QPushButton("按钮1", this);
    // QPushButton* btn2 = new QPushButton("按钮2", this);
    // resize(800, 600);

    // [=](){
    //     btn1->setText(("测试按钮1"));
    //     btn2->setText(("测试按钮2"));
    // }();

    //()
    // auto f = [](int x, int y){return x + y; };
    // int result = f(2, 3);
    // qDebug() << "result: " << result;

    //opt可选选项
    // QPushButton* Btn1 = new QPushButton("按钮1", this);
    // QPushButton* Btn2 = new QPushButton("按钮2", this);

    // int m = 10;

    // Btn1->move(800, 100);
    // Btn2->move(800, 100);

    // //添加mutable, 可以修改局部变量m的拷贝
    // connect(Btn1, &QPushButton::clicked, this, [m]()mutable{m = 20; qDebug() << "m= " << m; });
    // connect(Btn1, &QPushButton::clicked, this, [=](){qDebug() << "m= " << m; });

    // ui->setupUi(this);


    //->指定类型
    // auto f1 = []()->int{return 123; };
    // int result1 = f1();
    // qDebug() << "result1 = "<<result1;

    // auto f2 = []()->int{return 123; };
    // int result2 = f2();
    // qDebug() << "result2 = "<<result2;

    //Lambda表达式的函数体{ }可以为空
    // [](){};

}

Widget::~Widget()
{
    delete ui;
}
